package cn.stylefeng.guns.modular.business.frequency.cmlinkman.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.cmlinkman.service.CmLinkmanService;
import cn.stylefeng.guns.modular.business.frequency.cmlinkman.model.param.CmLinkmanParam;

import javax.annotation.Resource;

/**
 * 通讯录联系人表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class CmLinkmanController {

    @Resource
    private CmLinkmanService cmLinkmanService;

    /**
     * 分页查询通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmLinkman/page")
    @BusinessLog(title = "通讯录联系人表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CmLinkmanParam cmLinkmanParam) {
        return new SuccessResponseData(cmLinkmanService.page(cmLinkmanParam));
    }

    /**
     * 获取全部通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmLinkman/list")
    @BusinessLog(title = "通讯录联系人表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CmLinkmanParam cmLinkmanParam) {
        return new SuccessResponseData(cmLinkmanService.list(cmLinkmanParam));
    }

    /**
     * 查看详情通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmLinkman/detail")
    @BusinessLog(title = "通讯录联系人表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CmLinkmanParam.detail.class) CmLinkmanParam cmLinkmanParam) {
        return new SuccessResponseData(cmLinkmanService.detail(cmLinkmanParam));
    }

    /**
     * 添加通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmLinkman/add")
    @BusinessLog(title = "通讯录联系人表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CmLinkmanParam.add.class) CmLinkmanParam cmLinkmanParam) {
        cmLinkmanService.add(cmLinkmanParam);
        return new SuccessResponseData();
    }

    /**
     * 删除通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmLinkman/delete")
    @BusinessLog(title = "通讯录联系人表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CmLinkmanParam.delete.class) CmLinkmanParam cmLinkmanParam) {
        cmLinkmanService.delete(cmLinkmanParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmLinkman/edit")
    @BusinessLog(title = "通讯录联系人表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CmLinkmanParam.edit.class) CmLinkmanParam cmLinkmanParam) {
        cmLinkmanService.edit(cmLinkmanParam);
        return new SuccessResponseData();
    }

    /**
     * 修改状态
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmLinkman/changeStatus")
    @BusinessLog(title = "通讯录联系人表_修改状态", opType = LogAnnotionOpTypeEnum.CHANGE_STATUS)
    public ResponseData changeStatus(@RequestBody @Validated(CmLinkmanParam.changeStatus.class) CmLinkmanParam cmLinkmanParam) {
        cmLinkmanService.changeStatus(cmLinkmanParam);
        return new SuccessResponseData();
    }

}
